#include<pthread.h>
#include<iostream>
#include<string>
#include<unistd.h>
#include<cassert>
using namespace std;


void *func(void* args)
{
    string name = static_cast<const char*>(args);
    int cnt = 3;
    while(true)
    {
        cout<<"I am th1"<<endl;
        sleep(1);
    }
    return nullptr;
}

int main()
{
    string name = "th1";
    pthread_t th1;
    pthread_create(&th1,nullptr,func,(void*)name.c_str());

    cout<<"main try to join"<<endl;
    int res = pthread_join(th1,nullptr);
    if(res != 0)
    {
        cout<<"Running thread join"<<endl;
        assert(false);
    }
    cout<<"main tried"<<endl;

    return 0;
}